<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>oauth token</title>
    <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/jquery@1.11.1/dist/jquery.min.js"></script>
</head>
<body>
登陆中...
<br>
从浏览器控制台查看获取的token
<br>
<a href="#" onclick="index()">目标页</a>
<script>
    var targetUrl;
    window.onload = function () {
        console.log('tk: ' + '[[${tk}]]')
        console.log('username: ' + '[[${username}]]')
        console.log('id: ' + '[[${id}]]')
        $.ajax({
            // 如果用的是模板，则 url 可以使用注入的方式，会跟着配置动态改变
            url: '[[@{/oauth2Callback}]]',
            type: "POST",
            data: 'tk=[[${tk}]]&username=[[${username}]]&id=[[${id}]]',
            dataType: "json",
            success: function (data) {
                console.log("--------> 获取 /oauth2Callback 数据 成功")
                console.log("--------> 获取 token 数据")
                console.log(data)
                targetUrl = data.data.targetUrl;
            },
            error: function (data) {
                console.log("........> 获取 /oauth2Callback 数据 错误")
                console.log(data)
                console.log()
            }
        });

    }

    index = function () {
        window.location.href = targetUrl;
    }
</script>
</body>
</html>